
package com.monlyu.action.solution;

import java.io.File;
import java.io.InputStream;

import org.apache.commons.io.FileUtils;

import com.monlyu.action.system.DownloadAction;
import com.monlyu.bo.SolutionBo;
import com.monlyu.util.ContentType;
import com.monlyu.util.StringUtil;
import com.monlyu.vo.Solution;

/*******************************************************************************
 * <b>功能描述☞</b>导出编辑方案内容<br>
 * <b>开发公司☞</b>重庆唯尼科技有限公司<br>
 * <b>版权☞</b>本文件归重庆唯尼科技有限公司所有<br>
 * <b>项目名☞</b>news_cd<br>
 * <b>文件路径☞</b>com.monlyu.action.solution.DownloadSolutionAction.java<br>
 * <b>开发日期☞</b>2011-6-26 <br>
 * 
 * @author chendan
 * @since JDK 5
 * @version 1.0.8
 ******************************************************************************/
@SuppressWarnings("serial")
public class DownloadSolutionAction extends DownloadAction {

    private SolutionBo solutionBo;
    private InputStream inputStream;
    private Long solutionId;

    @Override
    public String execute() throws Exception{
        String path = solutionBo.downZip(solutionId);
        Solution solution = solutionBo.get(Solution.class, solutionId);
        inputStream = FileUtils.openInputStream(new File(path));
        filename = StringUtil.str2Iso8859_1(solution.getIssue()+".zip");
        contentType = ContentType._zip;
        return download();
    }

    public InputStream getInputStream(){
        return inputStream;
    }

    public void setInputStream(InputStream inputStream){
        this.inputStream = inputStream;
    }

    public void setSolutionId(Long solutionId){
        this.solutionId = solutionId;
    }

    public void setSolutionBo(SolutionBo solutionBo){
        this.solutionBo = solutionBo;
    }

}
